home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 32 / Mac Magazin and MacEasy Magazine CD - Issue 32.iso / Grafik & Text / OzTeX3.0 / TeX-inputs / Plain / boxedeps.tex < prev    next >
Text File  |  1995-01-26  |  28KB  |  858 lines

  1.   %%
  2.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3.   %%
  4.  %%%%%               boxedeps.tex 
  5.  %%%%% MACROS FOR FIGURE INSERTS OF EPSF NORM  %%%%%
  6.  %%%%%   (EPSF = Encapsulated PostScript File)
  7.   %%
  8.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9.   %%  
  10.  %%%  AUTHOR: Laurent Siebenmann
  11.   %%    lcs@topo.math.u-psud.fr
  12.   %%  
  13.  %%%  VERSIONS: Feb 1991 -- Jan 1995
  14.   %%  
  15.  %%%  SOMMAIRE: boxedeps.tex d\'efinit des macro-commandes
  16.   %%    qui permettent d'int\'egrer dans un document TeX des 
  17.   %%    objets graphiques d\'ecrits par fichier de norme EPSF,
  18.   %%    tout en accordant a chacun le statut d'une bo\^ite TeX ayant 
  19.   %%    les bonnes dimensions.  La (seule!) contribution unique 
  20.   %%    de ce fichier est de faire cela d'une fa{\c}con universelle.
  21.   %%    C'est a dire de fa{\c}con \`a pouvoir commod\'ement 
  22.   %%    servir avec tout pilote d'imprimante de norme 
  23.   %%    PostScript --- malgr\'e l'absence d'une norme 
  24.   %%    pour \special. 
  25.   %%  
  26.  %%%% ACTIVATION:
  27.   %%  by a driver-by-driver protocol
  28.   %%  see \SetTexturesEPSFSpecial 
  29.   %%  and its companions below.
  30.   %%  
  31.  %%%% DOCUMENTATION:
  32.   %%  --- see boxedeps.doc
  33.   %%  The complete utility is called BoxedEPSF
  34.   %%
  35.  %%%%  POSTINGS: anonymous ftp 
  36.   %%  ---  ftp matups.math.u-psud.fr [192.54.146.4] 
  37.   %%  This is the master copy in 1994.
  38.   %%  ---  ftp.uni-stuttgart.de 
  39.   %%  ---  ftp ftp.TeX.AC.UK
  40.   %%  ---  ftp ftp.SHSU.edu
  41.   %%  Locate the full package on these three 
  42.   %%  "CTAN" servers by using (while connected) the command
  43.   %%        QUOTE SITE INDEX boxedeps
  44.  
  45.  \ifx\MYUNDEFINED\BoxedEPSF
  46.    \let\temp\relax
  47.  \else
  48.    \message{}
  49.    \message{ !!! \string\BoxedEPSF or \string\BoxedArt %
  50.          macros already defined !!!}
  51.    \let\temp\endinput
  52.  \fi
  53.   \temp
  54.  
  55.  \chardef\EPSFCatAt\the\catcode`\@
  56.  \catcode`\@=11
  57.  
  58.  \chardef\C@tColon\the\catcode`\:
  59.  \chardef\C@tSemicolon\the\catcode`\;
  60.  \chardef\C@tQmark\the\catcode`\?
  61.  \chardef\C@tEmark\the\catcode`\!
  62.  \chardef\C@tDqt\the\catcode`\"
  63.  
  64.  \def\PunctOther@{\catcode`\:=12
  65.    \catcode`\;=12 \catcode`\?=12 \catcode`\!=12 \catcode`\"=12}
  66.  \PunctOther@
  67.  
  68.  %%temporarily suppress Plain's logging of allocations
  69.  \let\wlog@ld\wlog 
  70.  \def\wlog#1{\relax} 
  71.  
  72.  %% New for TOOLS
  73.  %\newif\ifIN@
  74.  \newdimen\XShift@ \newdimen\YShift@ 
  75.  \newtoks\Realtoks
  76.  
  77.  %%% New for BoxedEPSF
  78.  %
  79.  \newdimen\Wd@ \newdimen\Ht@
  80.  \newdimen\Wd@@ \newdimen\Ht@@
  81.  %
  82.  \newdimen\TT@
  83.  \newdimen\LT@
  84.  \newdimen\BT@
  85.  \newdimen\RT@
  86.  %
  87.  \newdimen\XSlide@ \newdimen\YSlide@ 
  88.  %
  89.  \newdimen\TheScale  %% secretly scale in mils: 1pt= 1mil 
  90.  \newdimen\FigScale  %% secretly scale in mils: 1pt= 1mil 
  91.  %
  92.  \newdimen\ForcedDim@@
  93.  
  94.  \newtoks\EPSFDirectorytoks@
  95.  \newtoks\EPSFNametoks@
  96.  \newtoks\BdBoxtoks@
  97.  \newtoks\LLXtoks@  %% useful info for Oz
  98.  \newtoks\LLYtoks@  
  99.  \newtoks\URXtoks@  %% further useful epsf.tex syntax
  100.  \newtoks\URYtoks@  
  101.  
  102.   
  103.  \newif\ifNotIn@
  104.  \newif\ifForcedDim@
  105.  \newif\ifForceOn@
  106.  \newif\ifForcedHeight@
  107.  \newif\ifPSOrigin
  108.  
  109.  \newread\EPSFile@ 
  110.  
  111.  %%%% MESSAGES (separate macro best for Europe)
  112.   %%  
  113.   \def\ms@g{\immediate\write16}
  114.  
  115.  %%%% WORD-PROCESSING MACROS
  116.   %%
  117.   %%% \IN@0#1@#2@ : Is 1st exp of #1 in 1st exp of #2 ??
  118.    %% Answer in \ifIN@
  119.  \newif\ifIN@\def\IN@{\expandafter\INN@\expandafter}
  120.   \long\def\INN@0#1@#2@{\long\def\NI@##1#1##2##3\ENDNI@
  121.     {\ifx\m@rker##2\IN@false\else\IN@true\fi}%
  122.      \expandafter\NI@#2@@#1\m@rker\ENDNI@}
  123.   \def\m@rker{\m@@rker}
  124.  
  125.   %%%  \SPLIT@0#1@#2@  :  Split 1st exp of #2 at 1st exp of #1
  126.    %%  \Initialtoks@ , \Terminaltoks@ will contain pieces
  127.   \newtoks\Initialtoks@  \newtoks\Terminaltoks@
  128.   \def\SPLIT@{\expandafter\SPLITT@\expandafter}
  129.   \def\SPLITT@0#1@#2@{\def\TTILPS@##1#1##2@{%
  130.      \Initialtoks@{##1}\Terminaltoks@{##2}}\expandafter\TTILPS@#2@}
  131.  
  132.  %%%% MACROS TO TRIM  \ForeTrim@0#1@ and \Trim@0#1@  
  133.    %% result appears in \Trimtoks@
  134.    %% LIMITATION: assume no multiple spaces to trim
  135.  
  136.   \newtoks\Trimtoks@
  137.  
  138.   %%% \ForeTrim@0#1@ trims initial space of first erpansion of #1
  139.    %% #1 of form \the\toks0 or \mymacro
  140.  \def\ForeTrim@{\expandafter\ForeTrim@@\expandafter}
  141.  \def\ForePrim@0 #1@{\Trimtoks@{#1}}
  142.  \def\ForeTrim@@0#1@{\IN@0\m@rker. @\m@rker.#1@%
  143.      \ifIN@\ForePrim@0#1@%
  144.      \else\Trimtoks@\expandafter{#1}\fi}
  145.    %%\m@rker expands here to \m@@rker since spot initial,
  146.    %% so no confusuion with \m@rker
  147.  
  148.   %%% \Trim@0#1@ trims init and terminal spaces 
  149.    %% Same syntax.
  150.    %% Warns if internal spaces found.
  151.    %% 
  152.   \def\Trim@0#1@{%
  153.       \ForeTrim@0#1@%
  154.       \IN@0 @\the\Trimtoks@ @%
  155.         \ifIN@ 
  156.              \SPLIT@0 @\the\Trimtoks@ @\Trimtoks@\Initialtoks@
  157.              \IN@0\the\Terminaltoks@ @ @%
  158.                  \ifIN@
  159.                  \else \Trimtoks@ {FigNameWithSpace}%
  160.                  \fi
  161.         \fi
  162.       }
  163.  
  164.  
  165.   %%%% MATH MACROS (provisional)
  166.     %% use dimen registers for reals; unit 1pt
  167.     %% (numerical dimension arguments OK unless contrary noted)
  168.  
  169.   %%%% One needs the point token seq (pt with cat 12) USES dimen 0
  170.    \newtoks\pt@ks
  171.    \def\getpt@ks 0.0#1@{\pt@ks{#1}}
  172.    \dimen0=0pt\relax\expandafter\getpt@ks\the\dimen0@
  173.  
  174.    %%% Convert dimen to "decimal multiplier"% USES dimens 0,2
  175.   %\newtoks\Realtoks% the output!
  176.   \def\Real#1{%
  177.     \dimen2=#1%
  178.       \SPLIT@0\the\pt@ks @\the\dimen2@%%  lop off the points
  179.        \Realtoks=\Initialtoks@ %\showthe\Realtoks
  180.             }
  181.  
  182.    %%% Multiplication 
  183.       % USES dimens 0,2,4,6; preserves args; output \Product
  184.    \newdimen\Product
  185.    \def\Mult#1#2{%
  186.      \dimen4=#1\relax
  187.      \dimen6=#2%
  188.      \Real{\dimen4}%
  189.      \Product=\the\Realtoks\dimen6%
  190.         }
  191.  
  192.    %%% Inverse 
  193.      % USES dimens 0; preserves arg; output \Inverse
  194.  \newdimen\Inverse
  195.  \newdimen\hmxdim@ \hmxdim@=8192pt%halfmaxdimen
  196.  \def\Invert#1{%
  197.   \Inverse=\hmxdim@
  198.   \dimen0=#1%
  199.   \divide\Inverse \dimen0%
  200.   \multiply\Inverse 8}
  201.  
  202.  %%% \Rescale#1#2#3  % USES dimens 0,2,4,6
  203.   %%  alters dimen register #1 by ratio #2/#3 
  204.   %%  where #2,#3 can be raw dimensions OR dimen registers
  205.    \def\Rescale#1#2#3{% Adequate accuracy. Can improve. 
  206.               \divide #1 by 100\relax
  207.               \dimen2=#3\divide\dimen2 by 100 \Invert{\dimen2}% 
  208.               \Mult{#1}{#2}%
  209.               \Mult\Product\Inverse 
  210.               #1=\Product}
  211.  
  212.  %%% \Scale#1 scales dimen register #1 
  213.   %%  by dimen register real \TheScale; USES dimens 0
  214.   \def\Scale#1{\dimen0=\TheScale 
  215.       \divide #1 by  1280 %% 1280*5120*10=1000*2^16 
  216.       \divide \dimen0 by 5120  
  217.       \multiply#1 by \dimen0 
  218.       \divide#1 by 10   %% max size of #1 about 32000/10 pt
  219.      }
  220.  
  221.  %%% SCRUNCHING BOXES AND SHIFTING CONTENTS
  222.   %% TeX has to do this in general
  223.   %% since some drivers do not let 
  224.   %% one do it readily using Postscript
  225.  
  226.  \newbox\scrunchbox
  227.  
  228.  %%% \Scrunched#1 puts #1 in an hbox
  229.   %%    then in effect zeros the dimensions of this box
  230.  \def\Scrunched#1{{\setbox\scrunchbox\hbox{#1}%
  231.    \wd\scrunchbox=0pt
  232.    \ht\scrunchbox=0pt
  233.    \dp\scrunchbox=0pt
  234.    \box\scrunchbox}}
  235.  
  236.   %%% \Shifted@#1 puts #1 in \hbox 
  237.    %% then locates basepoint to bottom left corner
  238.    %% then translates ink only by \XShift@,\YShift@
  239.    %% with Postscript convention
  240.    %% For simplicity use only on scrunched boxes
  241.   %\newdimen\XShift@ 
  242.   %\newdimen\YShift@ 
  243.  \def\Shifted@#1{%
  244.    \vbox {\kern-\YShift@
  245.        \hbox {\kern\XShift@\hbox{#1}\kern-\XShift@}%
  246.            \kern\YShift@}}
  247.  
  248.   %%% \cBoxedEPSF#1 the main macro
  249.    %%  component macros are explained in order below
  250.  
  251.  \def\cBoxedEPSF#1{{\leavevmode 
  252.     %% double brace for amstex \allign, \alligned, ...
  253.    \ReadNameAndScale@{#1}%
  254.    \SetEPSFSpec@
  255.    \ReadEPSFile@ \ReadBdB@x  
  256.    %% Calculations
  257.      \TrimFigDims@ 
  258.      \CalculateFigScale@  
  259.      \ScaleFigDims@
  260.      \SetInkShift@
  261.    \hbox{$\mathsurround=0pt\relax
  262.          \vcenter{\hbox{%
  263.              \FrameSpider{\hskip-.4pt\vrule}%
  264.              \vbox to \Ht@{\offinterlineskip\parindent=\z@%
  265.                 \FrameSpider{\vskip-.4pt\hrule}\vfil 
  266.                 \hbox to \Wd@{\hfil}%
  267.                 \vfil
  268.                 \InkShift@{\EPSFSpecial{\EPSFSpec@}{\FigSc@leReal}}%
  269.              \FrameSpider{\hrule\vskip-.4pt}}%
  270.          \FrameSpider{\vrule\hskip-.4pt}}}%
  271.      $\relax}%
  272.     \CleanRegisters@ 
  273.     \ms@g{ *** Box composed for the % 
  274.          EPS file \the\EPSFNametoks@}%
  275.     }}
  276.  
  277.  \def\tBoxedEPSF#1{\setbox4\hbox{\cBoxedEPSF{#1}}%
  278.      \setbox4\hbox{\raise -\ht4 \hbox{\box4}}%
  279.      \box4
  280.       }
  281.  
  282.  \def\bBoxedEPSF#1{\setbox4\hbox{\cBoxedEPSF{#1}}%
  283.      \setbox4\hbox{\raise \dp4 \hbox{\box4}}%
  284.      \box4
  285.       }
  286.  
  287.   \let\BoxedEPSF\cBoxedEPSF% default setting
  288.  
  289.   %% Some compatibility with BoxedArt.tex
  290.    %
  291.    \let\BoxedArt\BoxedEPSF
  292.  
  293.   %% Some compatibility with Sweet-teX
  294.    %
  295.   \def\gLinefigure[#1scaled#2]_#3{%
  296.         \BoxedEPSF{#3 scaled #2}}
  297.     
  298.   %% Some compatibility with Rokicki's dvips
  299.    %
  300.   \let\EPSFbox\bBoxedEPSF \let\EPSFfile\bBoxedEPSF
  301.   
  302.   \def\EPSFxsize{\afterassignment\ForceW@\ForcedDim@@}
  303.       \def\ForceW@{\ForcedDim@true\ForcedHeight@false}
  304.   
  305.   \def\EPSFysize{\afterassignment\ForceH@\ForcedDim@@}
  306.       \def\ForceH@{\ForcedDim@true\ForcedHeight@true}
  307.  
  308.   \def\EmulateRokicki{%
  309.        \let\epsfbox\bBoxedEPSF \let\epsffile\bBoxedEPSF
  310.        \let\epsfxsize\EPSFxsize \let\epsfysize\EPSFysize} 
  311.  
  312.  %%% \ReadNameAndScale@#1
  313.   %
  314.  \def\ReadNameAndScale@#1{\IN@0 scaled@#1@% DOUBLE BARRELED
  315.    \ifIN@\ReadNameAndScale@@0#1@%
  316.    \else \ReadNameAndScale@@0#1 scaled\DefaultMilScale @%
  317.    \fi}
  318.   
  319.  \def\ReadNameAndScale@@0#1scaled#2@{% HELPER MACRO
  320.     \let\OldBackslash@\\%
  321.     \def\\{\OtherB@ckslash}%
  322.     \edef\temp@{#1}%
  323.     \Trim@0\temp@ @%
  324.     \EPSFNametoks@\expandafter{\the\Trimtoks@ }%
  325.     \FigScale=#2 pt%
  326.     \let\\\OldBackslash@
  327.     }
  328.  
  329.  \def\SetDefaultEPSFScale#1{%
  330.       \global\def\DefaultMilScale{#1}}
  331.  
  332.  \SetDefaultEPSFScale{1000}
  333.  
  334.  
  335.  %%% \ReadEPSFile@
  336.   %
  337.  \def \SetBogusBbox@{%
  338.      \global\BdBoxtoks@{ BoundingBox:0 0 100 100 }%
  339.      \global\def\BdBoxLine@{ BoundingBox:0 0 100 100 }%
  340.      \ms@g{ !!! Will use placeholder !!!}%
  341.      }
  342.  
  343.  {\catcode`\%=12\gdef\P@S@{%!}\gdef\pct@@{%%}} %% %! min sign of PS file
  344.  
  345.  \def\ReadEPSFile@{%\show\EPSFSpec@%
  346.      \openin\EPSFile@\EPSFSpec@
  347.      \relax  %necessary to prevent precocious expansion of \ifeof
  348.   \ifeof\EPSFile@
  349.      \ms@g{}%
  350.      \ms@g{ !!! EPS FILE \the\EPSFDirectorytoks@
  351.        \the\EPSFNametoks@\space WAS NOT FOUND !!!}%
  352.      \SetBogusBbox@
  353.   \else%\fi
  354.    \begingroup%%
  355.    \catcode`\%=12\catcode`\:=12\catcode`\!=12
  356.    \catcode"00=14 \catcode"7F=14 \catcode`\\=14 
  357.     %% 14 = comment, terminates input line; 
  358.     %% 5 = CR just picks up extra space
  359.    \global\read\EPSFile@ to \BdBoxLine@ %\show\BdBoxLine@
  360.    \IN@0\P@S@ @\BdBoxLine@ @%
  361.    \ifIN@ %% %! accepted as %!PS so do BdBox search!!
  362.      \NotIn@true
  363.      \loop   
  364.        \ifeof\EPSFile@\NotIn@false 
  365.          \ms@g{}%
  366.          \ms@g{ !!! BoundingBox NOT FOUND IN %
  367.             \the\EPSFDirectorytoks@\the\EPSFNametoks@\space!!! }%
  368.          \SetBogusBbox@
  369.        \else\global\read\EPSFile@ to \BdBoxLine@
  370.        %\show\BdBoxLine@
  371.        \fi
  372.        \global\BdBoxtoks@\expandafter{\BdBoxLine@}%
  373.        \IN@0BoundingBox:@\the\BdBoxtoks@ @%
  374.        \ifIN@\NotIn@false\fi%
  375.      \ifNotIn@
  376.      \repeat
  377.    \else
  378.          \ms@g{}%
  379.          \ms@g{ !!! \the\EPSFNametoks@\space is not PostScript.}%
  380.          \ms@g{ !!! It should begin with the "\P@S@". }%
  381.          \ms@g{ !!! Also, all other header lines until }%
  382.          \ms@g{ !!!  "\pct@@ EndComments"  should begin with "\pct@@". }%
  383.          \SetBogusBbox@
  384.    \fi
  385.   \endgroup\relax
  386.   \fi
  387.   \closein\EPSFile@ 
  388.    }
  389.  
  390.  
  391.   %%% \ReadBdB@x
  392.    % Rmk For simplicity 0 not used in syntax 
  393.    %  of \ReadBdB@x@,  \ReadBdB@x@@ 
  394.   \def\ReadBdB@x{% PART 0
  395.    \expandafter\ReadBdB@x@\the\BdBoxtoks@ @}
  396.   
  397.   \def\ReadBdB@x@#1BoundingBox:#2@{% PART 1
  398.     \ForeTrim@0#2@%
  399.     \IN@0atend@\the\Trimtoks@ @%
  400.        \ifIN@ \Trimtoks@={0 0 100 100 }%
  401.          \ms@g{}%
  402.          \ms@g{ !!! BoundingBox not found in %
  403.          \the\EPSFDirectorytoks@\the\EPSFNametoks@\space !!!}%
  404.          \ms@g{ !!! It must not be at end of EPSF !!!}%
  405.          \ms@g{ !!! Will use placeholder !!!}%
  406.        \fi%% cf \SetBogusBbox@
  407.     \expandafter\ReadBdB@x@@\the\Trimtoks@ @%
  408.    }
  409.     
  410.   \def\ReadBdB@x@@#1 #2 #3 #4@{% PART 2
  411.       \Wd@=#3bp\advance\Wd@ by -#1bp%
  412.       \Ht@=#4bp\advance\Ht@ by-#2bp%
  413.        \Wd@@=\Wd@ \Ht@@=\Ht@ %% useful info for Clark
  414.        \LLXtoks@={#1}\LLYtoks@={#2}%% useful for Oz
  415.        \URXtoks@={#3}\URYtoks@={#4}%% useful for epsf.tex
  416.       \ifPSOrigin\XShift@=-#1bp\YShift@=-#2bp\fi 
  417.      }
  418.  
  419.   %%% \SetEPSFDirectory 
  420.    %
  421.    \def\G@bbl@#1{}
  422.    \bgroup
  423.      \global\edef\OtherB@ckslash{\expandafter\G@bbl@\string\\}
  424.    \egroup
  425.  
  426.   \def\SetEPSFDirectory{%  Part 1
  427.            \bgroup\PunctOther@\relax
  428.            \let\\\OtherB@ckslash
  429.            \SetEPSFDirectory@}
  430.  
  431.  \def\SetEPSFDirectory@#1{% Part 2
  432.     \edef\temp@{#1}%
  433.     \Trim@0\temp@ @%  result in \Trimtoks@
  434.     \global\toks1\expandafter{\the\Trimtoks@ }\relax
  435.     \egroup
  436.     \EPSFDirectorytoks@=\toks1
  437.     }
  438.  
  439.  \def\SetEPSFSpec@{%
  440.      \bgroup
  441.      \let\\=\OtherB@ckslash
  442.      \global\edef\EPSFSpec@{%
  443.         \the\EPSFDirectorytoks@\the\EPSFNametoks@}%
  444.      \global\edef\EPSFSpec@{\EPSFSpec@}%
  445.      \egroup}
  446.  
  447.  %%% \TrimFigDims@ 
  448.   % 
  449.  \def\TrimTop#1{\advance\TT@ by #1}
  450.  \def\TrimLeft#1{\advance\LT@ by #1}
  451.  \def\TrimBottom#1{\advance\BT@ by #1}
  452.  \def\TrimRight#1{\advance\RT@ by #1}
  453.  
  454.  \def\TrimBoundingBox#1{%
  455.    \TrimTop{#1}%
  456.    \TrimLeft{#1}%
  457.    \TrimBottom{#1}%
  458.    \TrimRight{#1}%
  459.        }
  460.  
  461.  \def\TrimFigDims@{%
  462.     \advance\Wd@ by -\LT@ 
  463.     \advance\Wd@ by -\RT@ \RT@=\z@
  464.     \advance\Ht@ by -\TT@ \TT@=\z@
  465.     \advance\Ht@ by -\BT@ 
  466.     }
  467.  
  468.  
  469.  %%% \CalculateFigScale@
  470.   %
  471.   \def\ForceWidth#1{\ForcedDim@true
  472.        \ForcedDim@@#1\ForcedHeight@false}
  473.   
  474.   \def\ForceHeight#1{\ForcedDim@true
  475.        \ForcedDim@@=#1\ForcedHeight@true}
  476.  
  477.   \def\ForceOn{\ForceOn@true}
  478.   \def\ForceOff{\ForceOn@false\ForcedDim@false}
  479.   
  480.   \def\CalculateFigScale@{%
  481.             %Have default \FigScale or read \FigScale
  482.      \ifForcedDim@\FigScale=1000pt% %% start afresh
  483.            \ifForcedHeight@
  484.                 \Rescale\FigScale\ForcedDim@@\Ht@
  485.            \else
  486.                 \Rescale\FigScale\ForcedDim@@\Wd@
  487.            \fi
  488.      \fi
  489.      \Real{\FigScale}%
  490.      \edef\FigSc@leReal{\the\Realtoks}%
  491.      }
  492.    
  493.   \def\ScaleFigDims@{\TheScale=\FigScale
  494.       \ifForcedDim@
  495.            \ifForcedHeight@ \Ht@=\ForcedDim@@  \Scale\Wd@
  496.            \else \Wd@=\ForcedDim@@ \Scale\Ht@
  497.            \fi
  498.       \else \Scale\Wd@\Scale\Ht@        
  499.       \fi
  500.       \ifForceOn@\relax\else\global\ForcedDim@false\fi
  501.       \Scale\LT@\Scale\BT@  %%%\Scale\Wd@\Scale\Ht@
  502.       \Scale\XShift@\Scale\YShift@
  503.       }
  504.       
  505.   %%% \ShowDisplacementBoxes
  506.    %%  shows (prints) corrected scaled and positioned
  507.    %%  bounding boxes; for diagnostics
  508.   %%% \HideDisplacementBoxes makes them invisible again
  509.    %%
  510.  \def\HideDisplacementBoxes{\global\def\FrameSpider##1{\null}}
  511.  \def\ShowDisplacementBoxes{\global\def\FrameSpider##1{##1}}
  512.  \let\HideFigureFrames\HideDisplacementBoxes %% some synonyms
  513.  \let\ShowFigureFrames\ShowDisplacementBoxes
  514.  \ShowDisplacementBoxes
  515.  
  516.   %%% \hSlide#1, \vSlide#1
  517.    %%
  518.  \def\hSlide#1{\advance\XSlide@ by #1}
  519.  \def\vSlide#1{\advance\YSlide@ by #1}
  520.  
  521.   %%% \SetInkShift@, \InkShift@#1
  522.    %%
  523.   \def\SetInkShift@{%
  524.             \advance\XShift@ by -\LT@
  525.             \advance\XShift@ by \XSlide@
  526.             \advance\YShift@ by -\BT@
  527.             \advance\YShift@ by -\YSlide@
  528.              }
  529.    %
  530.   \def\InkShift@#1{\Shifted@{\Scrunched{#1}}}
  531.  
  532.   %%% \CleanRegisters@
  533.    %
  534.   \def\CleanRegisters@{%
  535.       \globaldefs=1\relax
  536.         \XShift@=\z@\YShift@=\z@\XSlide@=\z@\YSlide@=\z@
  537.         \TT@=\z@\LT@=\z@\BT@=\z@\RT@=\z@
  538.       \globaldefs=0\relax}
  539.  
  540.  %%% Special syntax for several drivers. The macros 
  541.   %% \SetTexturesEPSFSpecial  %% Textures 
  542.   %% \SetUnixCoopEPSFSpecial %% dvi2ps early unix 
  543.   %% \SetBechtolsheimDVI2PSEPSFSpecial and 
  544.   %% \SetBechtolsheimDVITPSEPSFSpecial %% by S.P.Bechtolsheim
  545.   %% \SetLisEPSFSpecial %% dvi2ps by Tony Lis
  546.   %% \SetRokickiEPSFSpecial %% dvips by Tom Rokicki
  547.   %% \SetOzTeXEPSFSpecial %% OzTeX (>=1.7) by Andrew Trevorrow
  548.   %% \SetOldOzTeXEPSFSpecial %% OzTeX (1.42--1.6) 
  549.   %% \SetPSprintEPSFSpecial %% PSprint by Andrew Trevorrow
  550.   %%  --- also for OzTeX versions <= 1.41
  551.   %% \SetArborEPSFSpecial %% ArborTeX DVILASER/PS
  552.   %% \SetClarkEPSFSpecial %% dvitops by James Clark
  553.   %% \SetDVIPSoneEPSFSpecial %% DVIPSONE of Y&Y same as
  554.   %% \SetDVIWindowEPSFSpecial %% DVIWindow of Y&Y 
  555.   %% \SetBeebeEPSFSpecial %% DVIALW by N. Beebe
  556.   %% \SetNorthlakeEPSFSpecial %% Northlake Software
  557.   %% \SetDirectTeXEPSFSpecial %% DirectTeX by Wilfried Ricken
  558.   %% \SetCMacTeXEPSFSpecial %% CMacTeX by Tom Kiffe
  559.   %% \SetepsfEPSFSpecial %% will work for many:
  560.   %%  --- dvips, the Y&Y drivers, OzTeX>=1.7, DirectTeX, CMacTeX 
  561.   %% \SetStandardEPSFSpecial %% Nonexistant: Placebo below
  562.   %%
  563.   %% These many drivers are supported roughly
  564.   %% by (re-)defining the macro \EPSFSpecial#1#2, where
  565.   %% #1 = EPS file pathname (use \\ for the letter backslash)
  566.   %% #2 = scale in mils 
  567.   %% Be wary of using strange characters in pathnames!
  568.  
  569.  %% Textures, Blue Sky Research, Barry Smith
  570.  \def\SetTexturesEPSFSpecial{\PSOriginfalse%\PSOrigintrue
  571.   \gdef\EPSFSpecial##1##2{\relax
  572.     \edef\specialtemp{##2}%
  573.     \SPLIT@0.@\specialtemp.@\relax
  574.     \special{illustration ##1 scaled
  575.                         \the\Initialtoks@}}}
  576.  
  577.   %% Unix : dvi2ps by:  Mark Senn, Stephan  Bechtolsheim,  
  578.    % Bob  Brown, Richard, Furuta, James Schaad, Robert  Wells, 
  579.    % Norm Hutchinson, Neal Holt, Scott Jones, Howard Trickey.
  580.    % Introduced by B. Horn <bkph@ai.mit.edu>
  581.   \def\SetUnixCoopEPSFSpecial{\PSOrigintrue % Please test!
  582.    \gdef\EPSFSpecial##1##2{%
  583.       \dimen4=##2pt% convert real to dimen
  584.       \divide\dimen4 by 1000\relax
  585.       \Real{\dimen4}%dimens 0,2 used here
  586.       \edef\Aux@{\the\Realtoks}%  
  587.       %%convert dimen to real
  588.       \special{psfile=##1\space 
  589.         hscale=\Aux@\space
  590.         vscale=\Aux@}}}
  591.  
  592.  
  593.   %% dvi2ps and dvitps by S.P. Bechtolsheim,
  594.    % Introduced by B. Horn <bkph@ai.mit.edu> and Carl.M.Jones, 
  595.    % testing by R. Evans <Robert@cm.cardiff.ac.uk>
  596.    % and George Denk <denk@mathematik.tu-muenchen.de>
  597.    % Note that a prolog file psfig.pro
  598.    % specific to the driver should be available.
  599.   \def\SetBechtolsheimEPSFSpecial@{%% tool macro only
  600.    \PSOrigintrue
  601.    \special{\DriverTag@ Include0 "psfig.pro"}%
  602.    \gdef\EPSFSpecial##1##2{%
  603.       \dimen4=##2pt %% convert real to dimen
  604.       \divide\dimen4 by 1000\relax
  605.       \Real{\dimen4} %% dimens 0,2 used here
  606.       \edef\Aux@{\the\Realtoks}%% convert dimen to real
  607.       \special{\DriverTag@ Literal "10 10 0 0 10 10 startTexFig
  608.            \the\mag\space 1000 div 
  609.            dup 3.25 neg mul 1 index .25 neg mul translate %% correction line
  610.            \Aux@\space mul dup scale "}%
  611.       \special{\DriverTag@ Include1 "##1"}%
  612.       \special{\DriverTag@ Literal "endTexFig "}%
  613.         }}
  614.  
  615.   \def\SetBechtolsheimDVITPSEPSFSpecial{\def\DriverTag@{dvitps: }%
  616.       \SetBechtolsheimEPSFSpecial@}
  617.  
  618.   \def\SetBechtolsheimDVI2PSEPSFSSpecial{\def\DriverTag@{DVI2PS: }%
  619.       \SetBechtolsheimEPSFSpecial@}
  620.  
  621.   %% dvi2ps by Tony Lis,
  622.    % implantations? ; dates?; availability?
  623.    % Introduced by B. Horn <bkph@ai.mit.edu>
  624.   \def\SetLisEPSFSpecial{\PSOrigintrue 
  625.    \gdef\EPSFSpecial##1##2{%
  626.       \dimen4=##2pt% convert real to dimen
  627.       \divide\dimen4 by 1000\relax
  628.       \Real{\dimen4}% dimens 0,2 used here
  629.       \edef\Aux@{\the\Realtoks}%  
  630.       %%convert dimen to real
  631.       \special{pstext="10 10 0 0 10 10 startTexFig\space
  632.            \the\mag\space 1000 div \Aux@\space mul 
  633.            \the\mag\space 1000 div \Aux@\space mul scale"}%
  634.       \special{psfile=##1}%
  635.       \special{pstext=endTexFig}%
  636.         }}
  637.  
  638.   %% dvips by Tom Rokicki; free driver in portable C 
  639.    % Introduced by W.D. Neumann <neumann@mps.ohio-state.edu>
  640.   \def\SetRokickiEPSFSpecial{\PSOrigintrue 
  641.    \gdef\EPSFSpecial##1##2{%
  642.       \dimen4=##2pt% convert real to dimen
  643.       \divide\dimen4 by 10\relax
  644.       \Real{\dimen4}% dimens 0,2 used here
  645.       \edef\Aux@{\the\Realtoks}%  
  646.       %%convert dimen to real
  647.       \special{psfile="##1"\space 
  648.         hscale=\Aux@\space
  649.         vscale=\Aux@}}}
  650.  
  651.   \def\SetInlineRokickiEPSFSpecial{\PSOrigintrue 
  652.    \gdef\EPSFSpecial##1##2{%
  653.       \dimen4=##2pt% convert real to dimen
  654.       \divide\dimen4 by 1000\relax
  655.       \Real{\dimen4}% dimens 0,2 used here
  656.       \edef\Aux@{\the\Realtoks}%  
  657.       %%convert dimen to real
  658.       \special{ps::[begin] 10 10 0 0 10 10 startTexFig\space
  659.            \the\mag\space 1000 div \Aux@\space mul 
  660.            \the\mag\space 1000 div \Aux@\space mul scale}%
  661.       \special{ps: plotfile ##1}%
  662.       \special{ps::[end] endTexFig}%
  663.         }}
  664.  
  665.   %%% Rokicki's epsf.tex syntax.
  666.    %% Is followed by Direct TeX (W. Ricken)
  667.    %% and cMacTeX (Tom Kiffe) 
  668.    %% Is alternative syntax for Y&Y's drivers and
  669.    %% for OzTeX >= 1.7
  670.   \def\SetepsfEPSFSpecial{\PSOriginfalse 
  671.    \gdef\epsfclipstring{}%
  672.    %% make { clip} if you want to clip (non-portably)
  673.    %% down to the PostScript bounding box.
  674.    \gdef\EPSFSpecial##1##2{%
  675.       \dimen6=\the\URXtoks@ pt %% not bp!!!!!
  676.       \advance\dimen6 by -\the\LLXtoks@ pt
  677.       %\showthe\dimen6
  678.       %% \dimen6 now bbox width * points
  679.       \dimen4=##2pt %% convert mil scale to dimen
  680.       \divide\dimen4 by 100 %% 1000ths to 10ths
  681.       \Real{\dimen4}%% dimens 0,2 used here
  682.       \dimen6=\the\Realtoks\dimen6
  683.       \Real{\dimen6}%% dimens 0,2 used here
  684.       %% \Realtoks now holds decimal real no
  685.       %% 10 times desired "real width" (rwi) in bp
  686.       \special{PSfile=##1\space
  687.         llx=\the\LLXtoks@\space lly=\the\LLYtoks@\space
  688.         urx=\the\URXtoks@\space ury=\the\URYtoks@\space 
  689.     rwi=\the\Realtoks\space
  690.         \epsfclipstring}%
  691.        %\show\Special
  692.         }}
  693.     %% Minor Bug (my laziness): scaling not performed if bb width zero
  694.     %% Rmk: Under epsf.tex only multiples of (1/10) bp available widths
  695.     %% but considerably more accuracy available here.
  696.  
  697.     \let\SetDirectTeXEPSFSpecial=\SetepsfEPSFSpecial
  698.     \let\SetCMacTeXEPSFSpecial=\SetepsfEPSFSpecial
  699.     \let\SetOzTeXEPSFSpecial=\SetepsfEPSFSpecial
  700.  
  701.  %%% Old OzTeX versions (1.42 to 1.6), by Andrew Trevorrow.
  702.  %%% For versions <= 1.41 use \SetPSprintEPSFSpecial below.
  703.  %%% Version 1.42--1.5 may give spurious "offpage" error notices on printing.
  704.  \def\SetOldOzTeXEPSFSpecial{\PSOrigintrue
  705.  \gdef\EPSFSpecial##1##2{%
  706.  \dimen4=##2pt%% convert real to dimen
  707.  \divide\dimen4 by 1000\relax
  708.  \Real{\dimen4}%% dimens 0,2 used here
  709.  \edef\Aux@{\the\Realtoks}%% convert dimen to real
  710.  \special{epsf=\string"##1\string"\space scale=\Aux@}%
  711.  }} 
  712.  
  713.  %% PSprint, by AndrewTrevorrow for VaX VMS
  714.  %% and OzTeX versions <= 1.41  
  715.   % tested 2-91 by Max Calviani <ISICA@ASTRPD.infn.it>
  716.   \def\SetPSprintEPSFSpecial{\PSOriginfalse % artifice; see below
  717.    \gdef\EPSFSpecial##1##2{%note order
  718.      \special{##1\space 
  719.        ##2 1000 div \the\mag\space 1000 div mul
  720.        ##2 1000 div \the\mag\space 1000 div mul scale
  721.        \the\LLXtoks@\space neg \the\LLYtoks@\space neg translate
  722.        }}}
  723.  
  724.  %% DVILASER/PS driver originally written by David Fuchs
  725.   % marketed and supported by ArborTeXt  535 W. William St.
  726.   % Suite 300, Ann Arbor, MI 48103, U.S.A
  727.   % (313) 996-3566 (313) 996-3573
  728.   % help@arbortext.com, Andrew Dobrowolski
  729.  \def\SetArborEPSFSpecial{\PSOriginfalse % check!
  730.    \gdef\EPSFSpecial##1##2{%
  731.      \edef\specialthis{##2}%
  732.      \SPLIT@0.@\specialthis.@\relax % suppress decimals (nec!)
  733.      \special{ps: epsfile ##1\space \the\Initialtoks@}}}
  734.  
  735.  %% dvitops, (c) James Clark <jjc@jclark.uucp>
  736.   % public domain; distributed by UK TeX Archive
  737.   % computers: unix, msdos, vms, primos and vm/cms,
  738.   % introduced by S. Ratz <spqr@uk.ac.southampton.ecs>
  739.  \def\SetClarkEPSFSpecial{\PSOriginfalse % please test!
  740.    \gdef\EPSFSpecial##1##2{%
  741.      \Rescale {\Wd@@}{##2pt}{1000pt}%
  742.      \Rescale {\Ht@@}{##2pt}{1000pt}%
  743.      \special{dvitops: import 
  744.            ##1\space\the\Wd@@\space\the\Ht@@}}}
  745.  
  746.  %% DVIPSONE, for PC compatibles
  747.   % Y&Y, 106 Indian Hill, Carlisle MA 01741, USA
  748.   % (508) 371-3286
  749.   % (introduced by B. Horn <bkph@ai.mit.edu>)
  750.   \let\SetDVIPSONEEPSFSpecial\SetUnixCoopEPSFSpecial
  751.   \let\SetDVIPSoneEPSFSpecial\SetUnixCoopEPSFSpecial
  752.   \let\SetDVIWindowEPSFSpecial\SetUnixCoopEPSFSpecial
  753.  
  754.  %% DVIALW by N. Beebe, public domain 
  755.   % DVI Driver Distribution, Center for Scientific Computing,
  756.   % Department of Mathematics, 220 South Physics Building,
  757.   % University of Utah, Salt Lake City, UT 84112, USA
  758.   % (introduced by B. Horn <bkph@ai.mit.edu>)
  759.   % Proposed standard; see TUGboat article 1993.
  760.   \def\SetBeebeEPSFSpecial{%please test!
  761.    \PSOriginfalse% 
  762.    \gdef\EPSFSpecial##1##2{\relax
  763.     \special{language "PS",
  764.       literal "##2 1000 div ##2 1000 div scale",
  765.       position = "bottom left",
  766.       include "##1"}}}
  767.   \let\SetDVIALWEPSFSpecial\SetBeebeEPSFSpecial
  768.  
  769.  %% Northlake software
  770.   \def\SetNorthlakeEPSFSpecial{\PSOrigintrue
  771.    \gdef\EPSFSpecial##1##2{%
  772.      \edef\specialthis{##2}%
  773.      \SPLIT@0.@\specialthis.@\relax % suppress decimals (nec!)
  774.      \special{insert ##1,magnification=\the\Initialtoks@}}}
  775.  
  776.  %%% OzTeX (versions 1.7 and later),
  777.  %%% PLUS Textures, Blue Sky Research, Barry Smith
  778.  %%% PLUS (Inline) Rokicki dvips
  779.   %% experimental 11-94
  780.   \def\SetOzTeXRokickiTexturesEPSFMultiSpecial{\PSOriginfalse
  781.    \gdef\EPSFSpecial##1##2{%
  782.     \dimen4=##2pt%% convert real to dimen
  783.     \divide\dimen4 by 1000\relax
  784.     \Real{\dimen4}%% dimens 0,2 used here
  785.     \edef\Aux@{\the\Realtoks}%% convert dimen to real
  786.     \special{epsf=\string"##1\string"\space scale=\Aux@}%
  787.     %
  788.     \relax
  789.     \edef\specialtemp{##2}%
  790.     \SPLIT@0.@\specialtemp.@\relax
  791.     \special{illustration ##1 scaled \the\Initialtoks@}%
  792.     %
  793.     \dimen4=##2pt% convert real to dimen
  794.     \divide\dimen4 by 1000\relax
  795.     \Real{\dimen4}% dimens 0,2 used here
  796.     \edef\Aux@{\the\Realtoks}%  
  797.     %%convert dimen to real
  798.     \special{ps::[begin] 10 10 0 0 10 10 startTexFig\space
  799.          \the\mag\space 1000 div \Aux@\space mul 
  800.          \the\mag\space 1000 div \Aux@\space mul scale
  801.      \the\LLXtoks@\space neg \the\LLYtoks@\space neg translate
  802.      %% LLX, LLY the lower left corner 
  803.      }%
  804.     \special{ps: plotfile ##1}%
  805.     \special{ps::[end] endTexFig}%
  806.     }}
  807.  
  808.  \def\SetStandardEPSFSpecial{%
  809.    \gdef\EPSFSpecial##1##2{%
  810.      \ms@g{}
  811.      \ms@g{%
  812.        !!! Sorry! There is still no standard for \string%
  813.        \special\space EPSF integration !!!}%
  814.      \ms@g{%
  815.       --- So you will have to identify your driver using a command}%
  816.      \ms@g{%
  817.       --- of the form \string\Set...EPSFSpecial, in order to get}%
  818.      \ms@g{%
  819.       --- your graphics to print.  See BoxedEPS.doc.}%
  820.      \ms@g{}
  821.      \gdef\EPSFSpecial####1####2{}
  822.      }}
  823.  
  824.   \SetStandardEPSFSpecial %% currently gives warning
  825.  
  826.  \let\wlog\wlog@ld %%restore logging 
  827.  
  828.  \catcode`\:=\C@tColon
  829.  \catcode`\;=\C@tSemicolon
  830.  \catcode`\?=\C@tQmark
  831.  \catcode`\!=\C@tEmark
  832.  \catcode`\"=\C@tDqt
  833.  
  834.  \catcode`\@=\EPSFCatAt
  835.  
  836.   \endinput
  837.  
  838. %%%%%%%%%%%% ASCII Character test
  839.  %
  840.  %       Upper case letters: ABCDEFGHIJKLMNOPQRSTUVWXYZ
  841.  %       Lower case letters: abcdefghijklmnopqrstuvwxyz
  842.  %                                   Digits: 0123456789
  843.  % Square, curly, angle braces, parentheses: [] {} <> ()
  844.  %           Backslash, slash, vertical bar: \ / |
  845.  %                              Punctuation: . ? ! , : ;
  846.  %          Underscore, hyphen, equals sign: _ - =
  847.  %                Quotes--right left double: ' ` "
  848.  %"at", "number" "dollar", "percent", "and": @ # $ % &
  849.  %           "hat", "star", "plus", "tilde": ^ * + ~
  850.  %
  851.  %%%%%%%%%%%%%%%%%%%%%%%%
  852.  %
  853.  % Une seule erreur de transmission peut empoisoner un programme!
  854.  %
  855.  % A single transmission error can poison a whole program.
  856.  %
  857.  %%%%%%%%%%%%%%%%%%%%%%%%
  858.